<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<!--Converted with LaTeX2HTML 98.1 release (February 19th, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->


<title>Error Correction</title>
<meta name="description" content="Error Correction">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="STYLESHEET" href="acm-00541_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">

<h1><br clear="ALL"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">
Error Correction</a>&nbsp;</font></b></td></tr></tbody></table></center>
</h1>

<p>
A boolean matrix has the <em>parity property</em> when each row and each column has an even sum, i.e.
contains an even number of bits which are set. Here's a 4 x 4 matrix which has the parity property:

</p><p>
</p><pre>1 0 1 0
0 0 0 0
1 1 1 1
0 1 0 1
</pre>

<p>
The sums of the rows are 2, 0, 4 and 2. The sums of the columns are 2, 2, 2 and 2.

</p><p>

</p><p>
<br>
Your job is to write a program that reads in a matrix and checks if it has the parity property. If not,
your program should check if the parity property can be established by changing only one bit. If
this is not possible either, the matrix should be classified as corrupt.

</p><p>

</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">
Input</a>&nbsp;</font>
</h2>
The input file will contain one or more test cases. The first line of each test case contains one
integer <i>n</i> (<i>n</i>&lt;100), representing the size of the matrix. On the next <i>n</i> lines, there will be <i>n</i> integers
per line. No other integers than 0 and 1 will occur in the matrix. Input will be terminated by a value
of 0 for <i>n</i>.

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">
Output</a>&nbsp;</font>
</h2>
For each matrix in the input file, print one line. If the matrix already has the parity property, print
``<tt>OK</tt>". If the parity property can be established by changing one bit, print ``<tt>Change bit </tt>(<i>i</i>,<i>j</i>)" where <i>i</i>
is the row and <i>j</i> the column of the bit to be changed. Otherwise, print ``<tt>Corrupt</tt>".

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">
Sample Input</a>&nbsp;</font>
</h2>

<p>
</p><pre>4
1 0 1 0
0 0 0 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 0 1 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 1 1 0
1 1 1 1
0 1 0 1
0
</pre>

<p>

</p><h2><font color="#0070e8"><a name="SECTION0001004000000000000000">
Sample Output</a>&nbsp;</font>
</h2>

<p>
</p><pre>OK
Change bit (2,3)
Corrupt
</pre>

<p>

</p><p>
<br></p><hr>
<address>
<i>Miguel A. Revilla</i>
<br><i>1999-01-11</i>
</address>
</body></html>